using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class cms_admin_Main_m_leftmenu_function : System.Web.UI.UserControl
{
    string uID = "";
    string adm = "";
    #region[Page_Load]
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["uid"] != null) { uID = Session["uid"].ToString(); }
        if (Session["adm"] != null) { adm = Session["adm"].ToString(); }
        if (adm == "1") { pnQT.Visible = true; paDanhsach.Visible = true; } else { pnQT.Visible = false; paDanhsach.Visible = false; }
        if (!IsPostBack) { Viewimages(); ViewOrVisible(uID); }
    }
    #endregion
    #region[Viewimages]
    void Viewimages()
    {
        List<tbUsersDATA> list = tbUserDB.tbUsers_GetByID(uID);
        if (list.Count > 0)
        {
            if (list[0].uImg.Length > 0)
            {
                ltranh.Text = Hinhanh_resize(list[0].uImg.ToString());
            }
        }
        list.Clear();
        list = null;
    }
    #endregion
    #region[Refresh]
    void Refresh()
    {
        Response.Redirect("admin.aspx");
    }
    #endregion
    #region[Default]
    protected void lbtdefault_Click(object sender, EventArgs e)
    {
        Session["c"] = "gtqt";
        Session["ctrname"] = "qt";
        Refresh();
    }
    #endregion
    #region[Quantrithanhvien]
    protected void lbt_quantritv_Click(object sender, EventArgs e)
    {
        Session["c"] = "user";
        Session["ctrname"] = "qt";
        Refresh();
    }
    #endregion
    #region[Danhmucphongban]
    protected void lbtPhongban_Click(object sender, EventArgs e)
    {
        Session["c"] = "pb";
        Session["ctrname"] = "dm";
        Refresh();
    }
    #endregion
    #region[Danhmucchucvu]
    protected void lbtChucvu_Click(object sender, EventArgs e)
    {
        Session["c"] = "cv";
        Session["ctrname"] = "dm";
        Refresh();
    }
    #endregion
    #region[Gui de nghi]
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Session["c"] = "senddn";
        Session["ctrname"] = "denghi";
        Refresh();
    }
    #endregion
    #region[De nghi da gui]
    protected void lbtDagui_Click(object sender, EventArgs e)
    {
        Session["c"] = "dagui";
        Session["ctrname"] = "denghi";
        Refresh();
    }
    #endregion
    #region[De nghi nhan]
    protected void lbtDenghinhan_Click(object sender, EventArgs e)
    {
        Session["c"] = "denghinhan";
        Session["ctrname"] = "denghi";
        Refresh();
    }
    #endregion
    #region[Quan ly tieu chi]
    protected void lbtDanhmuctieuchi_Click(object sender, EventArgs e)
    {
        Session["c"] = "tieuchi";
        Session["ctrname"] = "dm";
        Refresh();
    }
    #endregion
    #region[Config]
    protected void lbtCauhinhhethong_Click(object sender, EventArgs e)
    {
        Session["c"] = "config";
        Session["ctrname"] = "qt";
        Refresh();
    }
    #endregion
    #region[Danhgiacanhan]
    protected void lbtDanhgiacanhan_Click(object sender, EventArgs e)
    {
        Session["c"] = "danhgiacanhan";
        Session["ctrname"] = "danhgia";
        Refresh();
    }
    #endregion
    #region[Danhgianhanvien]
    protected void lbtDanhgianhanvien_Click(object sender, EventArgs e)
    {
        Session["c"] = "danhgianhanvien";
        Session["ctrname"] = "danhgia";
        Refresh();
    }
    #endregion
    #region[Xemdanhgiacanhan]
    protected void lbtXemdanhgiacanhan_Click(object sender, EventArgs e)
    {
        Session["c"] = "xemdanhgiacanhan";
        Session["ctrname"] = "danhgia";
        Refresh();
    }
    #endregion
    #region[Xem danh gia nhan vien]
    protected void lbtXemdanhgianhanvien_Click(object sender, EventArgs e)
    {
        Session["c"] = "xemdanhgianhanvien";
        Session["ctrname"] = "danhgia";
        Refresh();
    }
    #endregion
    #region[Hinhanh_resize]
    protected string Hinhanh_resize(string imgpath)
    {
        string chuoi = "";
        if (imgpath.ToString().Trim().Length > 0)
        {
            try
            {
                if (imgpath.IndexOf(".swf") > 0)
                {
                    chuoi += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' border='0' width='150px' height='90'>\n";
                    chuoi += "<param name='movie' value='" + imgpath + "'>\n";
                    chuoi += "<param name='AllowScriptAccess' value='always'>\n";
                    chuoi += "<param name='quality' value='High'>\n";
                    chuoi += "<embed src='" + imgpath + "'\n";
                    chuoi += "pluginspage='http://www.macromedia.com/go/getflashplayer'\n";
                    chuoi += "type='application/x-shockwave-flash'\n";
                    chuoi += "allowscriptaccess='always'\n";
                    chuoi += "width='150'\n";
                    chuoi += "height='90'>\n";
                    chuoi += "</object>\n";
                }
                else
                {
                    System.Drawing.Image imgPhotoVert = System.Drawing.Image.FromFile(Server.MapPath(imgpath.ToString()));
                    int sourceWidth = imgPhotoVert.Width;
                    int sourceHeight = imgPhotoVert.Height;

                    float nPercent = 0;
                    float nPercentW = 0;
                    float nPercentH = 0;
                    if (sourceWidth > 200 || sourceHeight > 250)
                    {
                        nPercentW = ((float)200 / (float)sourceWidth);
                        nPercentH = ((float)250 / (float)sourceHeight);
                        if (nPercentH < nPercentW)
                        {
                            nPercent = nPercentH;
                        }
                        else
                        {
                            nPercent = nPercentW;
                        }
                        int destWidth = (int)(sourceWidth * nPercent);
                        int destHeight = (int)(sourceHeight * nPercent);
                        chuoi = "<img src=" + imgpath.ToString().Trim() + " border=0 width=" + destWidth + " height=" + destHeight + ">";

                    }
                    else
                    {
                        int destWidth = (int)(sourceWidth);
                        int destHeight = (int)(sourceHeight);
                        chuoi = "<img src=" + imgpath.ToString().Trim() + " border=0 width=" + destWidth + " height=" + destHeight + ">";

                    }
                }
            }
            catch { }
        }
        return chuoi;
    }
    #endregion
    #region[TruongChuyen_Danhgiacongnhan]
    protected void lbtDanhgia_Truongchuyen_Click(object sender, EventArgs e)
    {
        Session["c"] = "danhgiatruongchuyen";
        Session["ctrname"] = "danhgia";
        Refresh();
    }
    #endregion
    #region[Quandoc_Danhgia]
    protected void lbtDanhgia_Quandoc_Click(object sender, EventArgs e)
    {
        Session["c"] = "danhgiaquandoc";
        Session["ctrname"] = "danhgia";
        Refresh();
    }
    #endregion
    #region[Xemdanhgiacongnhan]
    protected void lbtXemdanhgiaCN_Click(object sender, EventArgs e)
    {
        Session["c"] = "xemdanhgiacongnhan";
        Session["ctrname"] = "danhgia";
        Refresh();
    }
    #endregion
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        Session["c"] = "bophan";
        Session["ctrname"] = "dm";
        Refresh();
    }
    void ViewOrVisible(string uid)
    {
        List<tbUsersDATA> list = tbUserDB.tbUsers_GetBySub(uid);
        if (list.Count > 0)
        {
            pnNhanvien.Visible = true;
        }
        else
        {
            pnNhanvien.Visible = false;
        }
        list.Clear();
        list = null;
    }
    protected void LinkButtonxemtimesheet_Click(object sender, EventArgs e)
    {
        Session["c"] = "viewtimesheet";
        Session["ctrname"] = "dm";
        Refresh();
    }
    protected void LinkButtontaotimesheet_Click(object sender, EventArgs e)
    {
        Session["c"] = "createtimesheet";
        Session["ctrname"] = "dm";
        Refresh();
    }
}
